package com.zjw.zy.coreui.fragment.adapter

import android.view.LayoutInflater
import android.view.ViewGroup
import com.zjw.zy.R
import com.zjw.zy.base.BaseRecyclerAdapter
import com.zjw.zy.bean.WsMessage
import com.zjw.zy.coreui.fragment.holder.WechatMessageHolder

/**
 * @author     ：zhong.jw
 * @date       ：Created in 2022/12/4 22:35
 * @description：
 */
class WechatListAdapter(listener: ItemListener<WechatMessageHolder>) :
    BaseRecyclerAdapter<WsMessage, WechatMessageHolder>(listener) {

    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): WechatMessageHolder {
        val inflate = LayoutInflater.from(parent.context)
            .inflate(R.layout.holder_wechat_message, parent, false)

        return WechatMessageHolder(inflate)
    }

    fun insertMessage(it: WsMessage) {
        data.add(it)
        notifyItemInserted(data.size - 1)
    }

    fun insertMessages(it: List<WsMessage>) {
        data.addAll(it)
        notifyItemInserted(data.size - 1)
    }
}